package com.eight.cloud.uid.controller;

import com.eight.cloud.core.global.result.Result;
import com.eight.cloud.uid.config.CachedGenerator;
import com.eight.cloud.uid.config.UidGeneratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName: UidController
 * @Author: TXC
 * @Date: 2025-09-09 10:21
 **/
@RestController
@RequestMapping("/uid")
public class UidController {
    @Resource
    private UidGeneratorService uidGeneratorService;

    @GetMapping(value = "/getUid")
    public Result<String> getUid(){
        return Result.ok(String.valueOf(uidGeneratorService.nextId()));
    }

    @GetMapping(value = "/parseUid")
    public Result<String> parseUid(Long uid){
        return Result.ok(uidGeneratorService.parse(uid));
    }
}
